<?php
namespace Content\Controller;
use Think\Controller;

/**
 * Class AdminTypeArticleController
 * @package Content\Controller
 * 文章控制器
 */
class AdminSingelpageController extends Controller {

    private $model_name = 'Singlepage';

    public function edit(){
        $model = D($this->model_name);
        if(IS_POST){
            $data = filterInput($_POST);
            if(!checked_cat_priv(get_module_session('Admin', 'user_role'),$data['nav'] , 'update')){
                $this->error(LANG('no_cat_opr_acc'));
                return;
            }
            $model->save($data);
            $this->success(LANG('save_success'));
            return;
        }else if(IS_GET){
            $data = filterInput($_GET);
            $id = $model->checked_need_add($data['pid']);
            if(!$id) {
                $id = $data['pid'];
                $obj = $model->queryObj($id, 'parentid');
            }else{
                $obj = $model->queryObj($id, 'id');
            }
            $this->assign('obj', $obj);
        }
        $this->display();
    }
}